#pragma once;
#include "ObjPtrBase.h"
#include <iterator>
class Object;

class ObjectIterator
{
public:
	friend Object;
	typedef const Object* value_type;
	typedef std::forward_iterator_tag iterator_category;

	ObjectIterator(ObjPtrBase* objPtr) :
	  objPtr(objPtr)
	{}

	const ObjectIterator& operator =(const ObjectIterator& other)
	{
		objPtr = other.objPtr;
		return *this;
	}

	bool operator ==(const ObjectIterator& other) const
	{
		return objPtr == other.objPtr;
	}

	bool operator !=(const ObjectIterator& other) const
	{
		return (!(*this==other));
	}

protected:
	ObjPtrBase* objPtr;
};


class ObjectInnerIterator : public ObjectIterator
{
public:
	
	Object* operator->() const
	{
		return objPtr->ptr;
	}

	Object* operator*() const
	{
		return objPtr->ptr;
	}

	ObjectInnerIterator(ObjPtrBase* objPtr) : ObjectIterator(objPtr){}

	ObjectIterator& operator++()
	{
		objPtr = objPtr->nextInner;
		return *this;
	}

	ObjectIterator operator++(int i)
	{
		ObjectIterator temp(*this);
		++(*this);
		return temp;
	}
};

class ObjectOuterIterator : public ObjectIterator
{
public:
	
	Object* operator->() const
	{
		return objPtr->owner;
	}

	Object* operator*() const
	{
		return objPtr->owner;
	}

	ObjectOuterIterator(ObjPtrBase* objPtr) : ObjectIterator(objPtr){}

	ObjectIterator& operator++()
	{
		objPtr = objPtr->nextOuter;
		return *this;
	}

	ObjectIterator operator++(int i)
	{
		ObjectIterator temp(*this);
		++(*this);
		return temp;
	}
};